﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Inspired.Euler
{
    public static class Problem053
    {
        /// <summary>
        /// How many values of C(n,r), for 1 = n = 100, exceed one-million?
        /// </summary>
        [EulerProblem(53, Title = "How many values of C(n,r), for 1 = n = 100, exceed one-million?")]
        public static long Solve()
        {
            //return Extensions.Combinatorics(5, 3);
            //return Extensions.Combinatorics(23, 10);
            return
                Enumerable.Range(1, 100).SelectMany(n =>
                Enumerable.Range(1, n), (n, r) => 
                    Extensions.Combinatorics(n, r))
                    .Count(c => c > 1000000);
        }
    }
}
